package work8;

import java.util.Scanner;

public class Quetion1 {
    public static void main(String[] args) {
        System.out.println("====构造大学生类对象====");
        // Scanner input = new Scanner(System.in, "GBK");
        Scanner input = new Scanner(System.in);

        while (true) {
            System.out.println("请输入空格分隔的学号、姓名、性别、年龄");
            System.out.print("(end结束程序):");
            String stuNo = input.next();
            if (stuNo.equals("end")) {
                break;
            }
            String name = input.next();
            char sex = input.next().charAt(0);
            int age = input.nextInt();
            Student student = new Student(name, sex, age, stuNo);
            student.learn();
            student.study();
            System.out.printf("大学生信息：%s\n", student.toString());
        }
        System.out.println("–––––––程序结束");
        input.close();
    }
}

class Human {
    public String name;
    public char sex;
    public int age;

    public Human(String name, char sex, int age) {
        this.name = name;
        this.sex = sex;
        this.age = age;
    }

    public void think() {
        System.out.printf("%s在思考...\n", this.name);
    }

}

class Pupil extends Human {
    public String stuNo;

    public Pupil(String name, char sex, int age, String stuNo) {
        super(name, sex, age);
        this.stuNo = stuNo;
    }

    public void learn() {
        System.out.printf("%s在学习...\n", this.name);
    }
}

class Student extends Pupil {
    public Student(String name, char sex, int age, String stuNo) {
        super(name, sex, age, stuNo);
    }

    public void study() {
        System.out.printf("%s在自习...\n", this.name);
    }

    public String toString() {
        return String.format("%s,%s,%c,%d", this.stuNo, this.name, this.sex, this.age);
    }
}